﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

namespace TB_WS.Class
{
    public class Event
    { 
        public static int insert_Event(int Seller_ID, string Event_Key,string Event_Value)
        {
            string sql = "insert into Event_Click values("+Seller_ID+",'" + Event_Key + "','" + Event_Value + "')";
            return Class.Unit.db_Conn.Nonquery(sql);
        }

        public static int get_Event_Count(string Event_Key,int Seller_ID)
        {
            string sql = "select count(*) from Event_Click where Event_Key='" + Event_Key + "' and Seller_ID="+Seller_ID;
            return Convert.ToInt32(Class.Unit.db_Conn.scalar(sql));
        }

        public static DataSet get_all_Event(int Seller_ID)
        {
            string sql = "select * from Event_Click where Seller_ID=" + Seller_ID.ToString();
            return Class.Unit.db_Conn.select(sql);
        }

        public static DataSet get_Event_Info(string Event_Key,int Seller_ID)
        {
            string sql = "select * from Event_Click where Event_Key='" + Event_Key + "' and Seller_ID="+Seller_ID;
            return Class.Unit.db_Conn.select(sql);
        }

        public static int Delete_Event(string Event_Key,int Seller_ID)
        {
            string sql = "delete from Event_Click where Event_Key='" + Event_Key + "' and Seller_ID="+Seller_ID;
            return Class.Unit.db_Conn.Nonquery(sql);
        }

        public static int update_Event(string Event_Key,string New_Event_Value,int Seller_ID)
        {
            string sql = "update Event_Click set Event_Value='"+New_Event_Value+"' where Event_Key='"+Event_Key+"' and Seller_ID=" + Seller_ID;
            return Class.Unit.db_Conn.Nonquery(sql);
        }
    }
}